package com.atguigu.guli.service.edu.controller.admin;


import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Chapter;
import com.atguigu.guli.service.edu.entity.Video;
import com.atguigu.guli.service.edu.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-10-26
 */
@RestController

@RequestMapping("/admin/edu/video")
public class AdminVideoController {
    @Autowired
    VideoService videoService;

    @PostMapping("addVideo")
    public R addVideo(@RequestBody Video video){
        boolean save = videoService.save(video);
        return R.ok();
    }
    //修改章节信息
    @PutMapping("editVideo")
    public R editVideo(@RequestBody Video video){
        videoService.updateById(video);
        return R.ok();
    }
    //删除章节信息
    @DeleteMapping("deleteVideo/{id}")
    public R deleteVideo(@PathVariable String id){
        videoService.removeById(id);
        return R.ok();
    }
    //根据id查询章节信息
    @GetMapping("getVideoById/{id}")
    public R getVideoById(@PathVariable String id){
        Video video = videoService.getById(id);
        return R.ok().data("item",video);
    }

}

